home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / archiver / ldiff12s.zip / LDE18.ASM < prev    next >
Assembly Source File  |  1989-07-15  |  11KB  |  448 lines

  1. ;-----------------------------------------------------------------------------;
  2. ; LDE18.asm Ä½Åæî┼ÆΦÄ«üiùΓôÇüj     (C) ÄOû╪ÿaòF NIFTY SDR SDI00147   1989/7/15;
  3. ;-----------------------------------------------------------------------------;
  4. ; ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@    èεû{ôIé╚âAâïâSâèâYâÇé═ë£æ║Äüé╠ébé≡ÄQÅ╞;
  5. ; ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ ü@ü@ü@ü@ ì\æóë╗â}âNâìé═î├É∞Äüé╠éαé╠é≡Ägùp;
  6. ;                                          ;
  7. ;   ì∞ɼû@:                                      ;
  8. ;       optasm é≡ Use THREADs for Smaller OBJ(N) é╔é╡é─âAâZâôâuâïé╖éΘ         ;
  9. ;                                          ;
  10. ;-----------------------------------------------------------------------------;
  11. include lms3.inc                    ; ìéæ¼ì\æóë╗â}âNâì
  12.                             ; (c)S.Furukawa
  13. include minimac.inc                    ; movseg movdat movdatb
  14. ;-----------------------------------------------------------------------------;
  15. data    segment    word public                ;
  16.     extrn    RBuff        : byte            ; ô╟ì₧é▌âoâbâtâ@
  17.     extrn    WBuff        : byte            ; Åæì₧é▌âoâbâtâ@
  18.     extrn    CrcTable    : word            ; éâéÆéâùpâeü[âuâï
  19.     extrn    CRC        : word            ; éâéÆéâ
  20.     extrn    DicSeg        : word            ; Ä½Åæâoâbâtâ@
  21.                             ;
  22.         WPoint        dw    ?        ; Åæì₧é▌â|âCâôâ^
  23.         InHandle    dw    ?        ; ôⁿù═ânâôâhâï
  24.         OutHandle    dw    ?        ; Åoù═ânâôâhâï
  25.         PushSp        dw    ?        ; éôéÉæ▐ö≡ùpâÅü[âN
  26.         SrcSize        dw    ?,?        ; âtâ@âCâïâTâCâY
  27.         DicSize        dw    ?,?        ;
  28.         CodeBuf        db    33 dup(?)    ; éWârâbâgùpâÅü[âN
  29.         CmpLen        dw    ?        ;
  30.         DicPag        dw    ?        ;
  31.         DicLen        dw    ?        ;
  32.         SBufLen        dw    ?        ;
  33.         CPoint        dw    ?        ;
  34.         SftFlg        db    ?        ;
  35.         EndSrcFlg    db    ?        ;
  36.         MatchLen    dw    ?        ;
  37.         MatchSeg    dw    ?        ;
  38.         MatchAdr    dw    ?        ;
  39.         BCD        dw    ?        ;
  40.         BCD2        dw    ?        ;
  41.         BCDSTR        db    14 dup(?)    ;
  42.                             ;
  43.         MINWORD        equ    3        ;
  44.         MAXWORD        equ    4003h        ;
  45. data    ends                        ;
  46.                             ;
  47. code    segment    byte public                ;
  48.     assume    cs:code,ds:data,es:data            ;
  49.                             ;
  50.     public        EnCode18            ;
  51.                             ;
  52.     WBUFFEND    equ    0fffh            ;
  53.     RBUFFEND    equ    7fffh            ;
  54.                             ;
  55. ;-------------------------------------------------------;
  56. ; ïñÆ╩âîâWâXâ^ò╧Éö                    ;
  57. ; ----------------                    ;
  58. ;    ds:[si]        â\ü[âXâ|âCâôâ^            ;
  59. ;-------------------------------------------------------;
  60. BEGIN    CodeFlush                    ;
  61.     mov    cx,CPoint                ;
  62.     mov    bx,offset CodeBuf            ;
  63.     sub    cx,bx                    ;
  64.     mov    di,WPoint                ;
  65.     .do                        ;
  66.         mov    al,[bx]                ;
  67.         inc    bx                ;
  68.         .if    <di a WBUFFEND>            ;
  69.             pushm    ax,bx,cx        ;
  70.             mov    dx,offset WBuff        ;
  71.             mov    cx,di            ;
  72.             mov    bx,OutHandle        ;
  73.             msdos    40h            ;
  74.             jc    ErrOut            ;
  75.             cmp    ax,cx            ;
  76.             jne    ErrOut            ;
  77.             popm    cx,bx,ax        ;
  78.             xor    di,di            ;
  79.         .endif                    ;
  80.         mov    WBuff[di],al            ;
  81.         inc    di                ;
  82.     .loop                        ;
  83.     mov    WPoint,di                ;
  84.     mov    SftFlg,1                ;
  85.     mov    CodeBuf,0                ;
  86.     mov    CPoint,(offset CodeBuf)+1        ;
  87.     ret                        ;
  88. ENDN    CodeFlush                    ;
  89. ;-------------------------------------------------------;
  90. ; âfü[â^Åoù═                        ;
  91. ; ----------                        ;
  92. ;    in    cx    ôKìçÆ╖                ;
  93. ;    des    --                    ;
  94. ;-------------------------------------------------------;
  95. BEGIN    OutPut                        ;
  96.     push    cx                    ;
  97.     dec    cx                    ;
  98.     mov    bx,CPoint                ;
  99.     .if    <z>                    ;
  100.         mov    al,[si]                ;
  101.         mov    [bx],al                ;
  102.         inc    bx                ;
  103.         mov    al,SftFlg            ;
  104.         or    CodeBuf,al            ;
  105.     .else                        ;
  106.         sub    cx,3                ;
  107.         mov    dx,MatchSeg            ;
  108.         mov    ax,MatchAdr            ;
  109.         sub    dx,DicSeg            ;
  110.         test    dh,00001000b            ;
  111.         .if    <nz>                ;
  112.             or    ax,8000h        ;
  113.             and    dh,11110111b        ;
  114.         .endif                    ;
  115.         mov    [bx],ax                ;
  116.         inc    bx                ;
  117.         inc    bx                ;
  118.         shl    dh,1                ;
  119.         shl    dh,1                ;
  120.         or    cx,dx                ;
  121.         xchg    ch,cl                ;
  122.         mov    [bx],cx                ;
  123.         inc    bx                ;
  124.         inc    bx                ;
  125.     .endif                        ;
  126.     mov    CPoint,bx                ;
  127.     shl    SftFlg,1                ;
  128.     .if    <c>                    ;
  129.         call    CodeFlush            ;
  130.     .endif                        ;
  131.     pop    cx                    ;
  132.     ret                        ;
  133. ENDN    OutPut                        ;
  134. ;-------------------------------------------------------;
  135. ; ébéqébîvÄZ                        ;
  136. ; ----------                        ;
  137. ;    in    cx,dx                    ;
  138. ;    out    --                    ;
  139. ;    des    --                    ;
  140. ;-------------------------------------------------------;
  141. BEGIN    CrcCalc                        ;
  142.     .if    <cxnz>                    ;
  143.         pushm    si,dx,cx,bx,ax            ;
  144.         mov    si,dx                ;
  145.         mov    dx,CRC                ;
  146.         .do                    ;
  147.             lodsb                ;
  148.             mov    bl,dl            ;
  149.             xor    bh,bh            ;
  150.             xor    bl,al            ;
  151.             shl    bx,1            ;
  152.             mov    ax,CrcTable[bx]        ;
  153.             mov    bl,dh            ;
  154.             xor    bh,bh            ;
  155.             xor    bx,ax            ;
  156.             mov    dx,bx            ;
  157.         .loop                    ;
  158.         mov    CRC,dx                ;
  159.         popm    ax,bx,cx,dx,si            ;
  160.     .endif                        ;
  161.     ret                        ;
  162. ENDN    CrcCalc                        ;
  163. ;-------------------------------------------------------;
  164. ; âfü[â^ô╟é▌ì₧é▌                    ;
  165. ; --------------                    ;
  166. ;    in    cx                    ;
  167. ;-------------------------------------------------------;
  168. BEGIN    ReSetBuf                    ;
  169.     add    si,cx                    ;
  170.     sub    SBufLen,cx                ;
  171.     mov    ax,SBufLen                ;
  172.     .if    <ax b CmpLen>                ;
  173.         .if    <EndSrcFlg e FALSE>        ;
  174.             mov    di,offset RBuff        ;
  175.             mov    cx,(offset RBuff)+8003h    ;
  176.             sub    cx,si            ;
  177.             movseg    es,ds            ;
  178.             rep    movsb            ;
  179.             mov    dx,di            ;
  180.             mov    cx,(offset RBuff)+8003h    ;
  181.             sub    cx,di            ;
  182.             .if    <SrcSize[2] e 0 and <cx a SrcSize>>
  183.                 mov    cx,SrcSize    ;
  184.                 mov    EndSrcFlg,TRUE    ;
  185.             .endif                ;
  186.             add    SBufLen,cx        ;
  187.             mov    bx,InHandle        ;
  188.             msdos    3fh            ;
  189.             jc    ErrOut            ;
  190.             cmp    ax,cx            ;
  191.             jne    ErrOut            ;
  192.             call    CrcCalc            ;
  193.             sub    SrcSize,ax        ;
  194.             sbb    SrcSize[2],0        ;
  195.             mov    si,offset RBuff        ;
  196.             mov    ax,SBufLen        ;
  197.             .if    <ax b CmpLen>        ;
  198.                 mov    CmpLen,ax    ;
  199.             .endif                ;
  200.         .else                    ;
  201.             mov    CmpLen,ax        ;
  202.         .endif                    ;
  203.     .endif                        ;
  204.       ret                        ;
  205. ENDN    ReSetBuf                    ;
  206. ;-------------------------------------------------------;
  207. ; îƒì⌡   SI  -->  CX
  208. ;-------------------------------------------------------;
  209. BEGIN    Search                        ;
  210.     mov    es,DicSeg                ;
  211.     xor    di,di                    ;
  212.     mov    dx,DicPag                ;
  213.     mov    MatchLen,MINWORD            ;
  214.     .if    <CmpLen be MINWORD>            ;
  215.         jmp    #out                ;
  216.     .endif                        ;
  217.     .if    <dx ne 0>                ;
  218.         mov    cx,8000h            ;
  219.     .else                        ;
  220.         mov    cx,DicLen            ;
  221.     .endif                        ;
  222.     .do    lp                    ;
  223.         .do                    ;
  224.             .if    <dx e 0 and <cx be MINWORD>>
  225.                 jmp    #out        ;
  226.             .endif                ;
  227.             .if    <cx e 0>        ;
  228.                 dec    dx        ;
  229.                 mov    ax,es        ;
  230.                 add    ax,800h        ;
  231.                 mov    es,ax        ;
  232.                 xor    di,di        ;
  233.                 .if    <dx e 0>    ;
  234.                     mov    cx,DicLen
  235.                 .else            ;
  236.                     mov    cx,8000h
  237.                 .endif            ;
  238.             .endif                ;
  239.             or    cx,cx            ;
  240.             mov    al,[si]            ;
  241.             repnz    scasb            ;
  242.         .enddo    <nz>                ;
  243.         .if    <cx be MatchLen>        ;
  244.             .break    <dx e 0>        ;
  245.             mov    ax,DicLen        ;
  246.             .break    <dx e 1 and <ax b MatchLen>>
  247.         .endif                    ;
  248.         pushm    cx,dx,si,di            ;
  249.         inc    cx                ;
  250.         .if    <cx a CmpLen>            ;
  251.             mov    cx,CmpLen        ;
  252.         .else                    ;
  253.             .if    <dx e 1>        ;
  254.                 add    cx,DicLen    ;
  255.             .elseif    <dx a 1>        ;
  256.                 add    cx,8000h    ;
  257.             .endif                ;
  258.             .if    <cx a CmpLen>        ;
  259.                 mov    cx,CmpLen    ;
  260.             .endif                ;
  261.         .endif                    ;
  262.         dec    di                ;
  263.         mov    dx,di                ;
  264.         mov    bx,cx                ;
  265.         xor    al,al                ;
  266.         repz    cmpsb                ;
  267.         .if    <z>                ;
  268.             popm    di,si,ax,ax        ;
  269.             mov    MatchLen,bx        ;
  270.             mov    MatchAdr,dx        ;
  271.             mov    MatchSeg,es        ;
  272.             .break                ;
  273.         .else                    ;
  274.             sub    bx,cx            ;
  275.             dec    bx            ;
  276.             .if    <bx a MatchLen>        ;
  277.                 mov    MatchLen,bx    ;
  278.                 mov    MatchAdr,dx    ;
  279.                 mov    MatchSeg,es    ;
  280.             .endif                ;
  281.         .endif                    ;
  282.         popm    di,si,dx,cx            ;
  283.     .enddo    <>                    ;
  284. #out:    mov    cx,MatchLen                ;
  285.     .if    <cx be MINWORD>                ;
  286.         mov    cx,1                ;
  287.     .endif                        ;
  288.     ret                        ;
  289. ENDN    Search                        ;
  290. ;-------------------------------------------------------;
  291. ; âJâEâôâgò\Ī CX
  292. ;-------------------------------------------------------;
  293. BEGIN    Display                        ;
  294.     push    cx                    ;
  295.     .if    <cx e 1>                ;
  296.         mov    ax,BCD                ;
  297.         inc    al                ;
  298.         daa                    ;
  299.         xchg    ah,al                ;
  300.         adc    al,0                ;
  301.         daa                    ;
  302.         xchg    ah,al                ;
  303.         mov    BCD,ax                ;
  304.         and    ax,0f0fh            ;
  305.         or    ax,3030h            ;
  306.         mov    BCDSTR[3],ah            ;
  307.         mov    BCDSTR[5],al            ;
  308.         mov    ax,BCD                ;
  309.         mov    cl,4                ;
  310.         shr    ax,cl                ;
  311.         and    ax,0f0fh            ;
  312.         or    ax,3030h            ;
  313.         mov    BCDSTR[2],ah            ;
  314.         mov    BCDSTR[4],al            ;
  315.     .else                        ;
  316.         mov    ax,BCD2                ;
  317.         inc    al                ;
  318.         daa                    ;
  319.         xchg    ah,al                ;
  320.         adc    al,0                ;
  321.         daa                    ;
  322.         xchg    ah,al                ;
  323.         mov    BCD2,ax                ;
  324.         and    ax,0f0fh            ;
  325.         or    ax,3030h            ;
  326.         mov    BCDSTR[10],ah            ;
  327.         mov    BCDSTR[12],al            ;
  328.         mov    ax,BCD2                ;
  329.         mov    cl,4                ;
  330.         shr    ax,cl                ;
  331.         and    ax,0f0fh            ;
  332.         or    ax,3030h            ;
  333.         mov    BCDSTR[9],ah            ;
  334.         mov    BCDSTR[11],al            ;
  335.     .endif                        ;
  336.     mov    bx,2                    ;
  337.     mov    cx,14                    ;
  338.     mov    dx,offset BCDSTR            ;
  339.     msdos    40h                    ;
  340.     pop    cx                    ;
  341.     ret                        ;
  342. ENDN    Display                        ;
  343. ;-------------------------------------------------------;
  344. ; Åëè·ë╗              --> SI
  345. ;-------------------------------------------------------;
  346. BEGIN    Init                        ;
  347.     mov    BCD,1                    ;
  348.     mov    BC